{% extends "base_generic.html" %}
{% load static %}

{% block content %}
<div class="container mt-4">
    <div class="card">
        <div class="card-header bg-primary text-white">
            <h1 class="mb-0"><i class="fas fa-book"></i> 添加书籍副本</h1>
        </div>
        <div class="card-body">
            <form action="" method="post">
                {% csrf_token %}
                <div class="row">
                    <div class="col-md-6 mb-3">
                        <label for="id_book" class="form-label">书籍:</label>
                        <select id="id_book" name="book" class="form-select" required>
                            <option value="" selected>---------</option>
                            {% for book in form.book.field.queryset %}
                                <option value="{{ book.id }}">{{ book.title }}</option>
                            {% endfor %}
                        </select>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="id_imprint" class="form-label">版本信息:</label>
                        <input type="text" id="id_imprint" name="imprint" class="form-control">
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="id_due_back" class="form-label">预计归还日期:</label>
                        <input type="date" id="id_due_back" name="due_back" class="form-control">
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="id_status" class="form-label">状态:</label>
                        <select id="id_status" name="status" class="form-select" required>
                            <option value="" selected>---------</option>
                            {% for value, label in form.status.field.choices %}
                                {% if value %}
                                    <option value="{{ value }}">{{ label }}</option>
                                {% endif %}
                            {% endfor %}
                        </select>
                    </div>
                    <div class="col-md-6 mb-3">
                        <label for="id_borrower" class="form-label">借阅者:</label>
                        <select id="id_borrower" name="borrower" class="form-select">
                            <option value="">---------</option>
                            {% for borrower in form.borrower.field.queryset %}
                                <option value="{{ borrower.id }}">{{ borrower.username }}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>
                <div class="text-end">
                    <a href="{% url 'bookinstances' %}" class="btn btn-secondary">取消</a>
                    <button type="submit" class="btn btn-primary">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}